<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	@@include('public/title.html')
	<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge">
	<link href="../../css/bootstrap.min.css" rel="stylesheet">
	<link href="css/nifty.min.css" rel="stylesheet">
	<link href="../../css/demo/nifty-demo-icons.min.css" rel="stylesheet">
	<link href="../../plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
	<link href="../../css/user_defined.css" rel="stylesheet">
	<link href="../../plugins/pace/pace.min.css" rel="stylesheet">
	<script src="../../plugins/pace/pace.min.js?2016/8/5"></script>
	<script src="../../js/jquery-2.2.1.min.js"></script>
</head>
<body id="main">
<div id="container" class="effect mainnav-lg">
	@@include('public/header.html')
	<div class="boxed">
		<div id="content-container">
			<div id="page-title">
				<h1 class="page-header text-overflow">自有工程师管理</h1>
			</div>
			
			<div id="page-content">
				<button class="btn btn-primary" data-toggle="modal" data-target="#myModal">添加自有工程师</button>
			</div>
			
			<div class="row mar-top pad-top pad-all">
				<style>
					table {
						width:100%;
						color: #999;
						margin:auto;
					}
					
					td,th{
						padding: 10px;
						border:1px solid #bbbbbb;
						text-align:center;
					}
					td{
						cursor:pointer;
					}
					tr:hover{
						background:#f0f0f0;
					}
					th{
						text-align: center;
						background: #e6e6e6;
					}
					
					select{
						padding:5px;
						margin-right:20px;
					}
				</style>
				 <div class="text-right">
                    <button class="btn btn-primary" v-on:click="page(-1)" v-show="currentPage>0">上一页</button>
                    <button class="btn btn-primary" v-on:click="page(1)">下一页</button>
                </div>
				<table>
					<tr>
						<th width="150">工程师姓名</th>
						<th width="350">绑定手机号</th>
						<th width="350">负责区域</th>
					</tr>
					<tr v-for="p in partners" v-on:click="partnerDetail(p);">
						<td width="350" v-text="p.m_name"></td>
						<td><div v-text="p.m_account"></div></td>
						<td><div v-text="p.city"></div></td>
					</tr>
				</table>
			</div>
			<!--End page content-->
		</div>
		
		<nav id="mainnav-container">
			@@include('public/left_menu.html')
		</nav>
	
	</div>
	
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h4 class="modal-title" id="myModalLabel">添加自有工程师</h4>
				</div>
				<div class="modal-body">
					<style>
						form{
							text-align: center;
						}
						form select, form input{
							width:200px;
							margin:15px 0;
							padding:5px;
						}
					</style>
					<validator name="validation">
					<form class="form-horizontal">
						<div>
							<span>工程师姓名 : </span>
							<span>
								<input
									type="type"
									v-model="member.name"
									name="name"
									v-validate:province="{required:member.name}"
									autocomplete="off">
							</span>
						</div>
						<div>
							<span>绑定手机号 : </span>
							<span>
								<input
									type="number"
									v-model="member.account"
									name="acc"
									v-validate:province="{required:member.account}"
									autocomplete="off">
							</span>
						</div>
						<div>
							<span>登陆密码  : </span>
							<span><input
								type="number"
								v-model="member.password"
								name="pwd"
								v-validate:province="{required:member.password}"
								autocomplete="off"></span>
						</div>
					</form>
					</validator>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" v-on:click="addStore()" :disabled="!$validation.valid" id="addBrand">确定添加</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
</div>
@@include('public/footer.html')
<script src="js/vue-validator.min.js"></script>
<script>
var vue = new Vue({
	el: '#main',
	data: {
		"cities":[],
		"provinces":[],
		"province":'',
		"city":"",
		"member":{},
		partners:'',
		statuses:["关闭","开启"],
		currentPage:0
	},
	methods: {
		/*添加工程师*/
		addStore:function(){
			$.post(apiRecycle+"partner.php/Admin/Member/add_member", {
				m_name:vue.member.name,
				m_account:vue.member.account,
				m_pwd:vue.member.password,
				m_type:3 /*自有工程师*/
			}, function(res){
				if(res.code==200){
					location.reload();
				} else {
					alert(res.message);
				}
			}, "json");
		},
		
		/*跳转到城市合伙人详情页面*/
		partnerDetail:function(p){
			location.href = "self_engineer_detail.html?member_id="+p.member_id;
		},
		
		/*获取工程师的列表*/
		loadStores:function(){
			var thiz = this;
			/*获取自有工程师*/
			$.get(apiRecycle+"partner.php/Admin/Member/get_member_list", {
				type:3,
				offset:thiz.currentPage*20,
				limit:20
			}, function(res){
				vue.partners = res.data;
			}, "json");
		},
		
		/*分页加载*/
		page:function(next){
			var thiz = this;
			thiz.currentPage += parseInt(next);
			if(thiz.currentPage<0){
				thiz.currentPage = 0;
			}
			this.loadStores();
		}
	},
	ready: function () {
		/*获取门店*/
		this.loadStores();
	}
});
</script>
</body>
</html>
